/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */
package model.entity;

import com.alibaba.fastjson.annotation.JSONField;
import java.io.Serializable;
import java.util.List;
import javax.persistence.Basic;
import javax.persistence.CascadeType;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.ManyToMany;
import javax.persistence.NamedQueries;
import javax.persistence.NamedQuery;
import javax.persistence.OneToMany;
import javax.persistence.Table;
import javax.validation.constraints.Size;
import javax.xml.bind.annotation.XmlRootElement;
import javax.xml.bind.annotation.XmlTransient;

/**
 *
 * @author dingnangen
 */
@Entity
@Table(name = "depot")
@XmlRootElement
@NamedQueries({
    @NamedQuery(name = "Depot.findAll", query = "SELECT d FROM Depot d"),
    @NamedQuery(name = "Depot.findByIddepot", query = "SELECT d FROM Depot d WHERE d.iddepot = :iddepot"),
    @NamedQuery(name = "Depot.findByName", query = "SELECT d FROM Depot d WHERE d.name = :name"),
    @NamedQuery(name = "Depot.findByLongitude", query = "SELECT d FROM Depot d WHERE d.longitude = :longitude"),
    @NamedQuery(name = "Depot.findByLatitude", query = "SELECT d FROM Depot d WHERE d.latitude = :latitude"),
    @NamedQuery(name = "Depot.findByAddress", query = "SELECT d FROM Depot d WHERE d.address = :address")})
public class Depot implements Serializable {

    private static final long serialVersionUID = 1L;
    @Id
    @GeneratedValue(strategy = GenerationType.IDENTITY)
    @Basic(optional = false)
    @Column(name = "iddepot")
    private Integer iddepot;
    @Size(max = 45)
    @Column(name = "name")
    private String name;
    // @Max(value=?)  @Min(value=?)//if you know range of your decimal fields consider using these annotations to enforce field validation
    @Column(name = "longitude")
    private Double longitude;
    @Column(name = "latitude")
    private Double latitude;
    @Size(max = 45)
    @Column(name = "address")
    private String address;
    @JSONField(label = "extask")
    @ManyToMany(mappedBy = "depotList")
    private List<Manager> managerList;
    @JSONField(label = "extask")
    @OneToMany(mappedBy = "iddepot")
    private List<Vehicle> vehicleList;
    @JSONField(label = "extask")
    @OneToMany(cascade = CascadeType.ALL, mappedBy = "iddepot")
    private List<Problem> problemList;
    @OneToMany(mappedBy = "iddepot")
    @JSONField(label = "extask")
    private List<Driver> driverList;
    @JSONField(label = "extask")
    @OneToMany(mappedBy = "iddepot")
    private List<Attendance> attendanceList;

    public Depot() {
    }

    public Depot(Integer iddepot) {
        this.iddepot = iddepot;
    }

    public Integer getIddepot() {
        return iddepot;
    }

    public void setIddepot(Integer iddepot) {
        this.iddepot = iddepot;
    }

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    public Double getLongitude() {
        return longitude;
    }

    public void setLongitude(Double longitude) {
        this.longitude = longitude;
    }

    public Double getLatitude() {
        return latitude;
    }

    public void setLatitude(Double latitude) {
        this.latitude = latitude;
    }

    public String getAddress() {
        return address;
    }

    public void setAddress(String address) {
        this.address = address;
    }

    @XmlTransient
    public List<Manager> getManagerList() {
        return managerList;
    }

    public void setManagerList(List<Manager> managerList) {
        this.managerList = managerList;
    }

    @XmlTransient
    public List<Vehicle> getVehicleList() {
        return vehicleList;
    }

    public void setVehicleList(List<Vehicle> vehicleList) {
        this.vehicleList = vehicleList;
    }

    @XmlTransient
    public List<Problem> getProblemList() {
        return problemList;
    }

    public void setProblemList(List<Problem> problemList) {
        this.problemList = problemList;
    }

    @XmlTransient
    public List<Driver> getDriverList() {
        return driverList;
    }

    public void setDriverList(List<Driver> driverList) {
        this.driverList = driverList;
    }

    @XmlTransient
    public List<Attendance> getAttendanceList() {
        return attendanceList;
    }

    public void setAttendanceList(List<Attendance> attendanceList) {
        this.attendanceList = attendanceList;
    }

    @Override
    public int hashCode() {
        int hash = 0;
        hash += (iddepot != null ? iddepot.hashCode() : 0);
        return hash;
    }

    @Override
    public boolean equals(Object object) {
        // TODO: Warning - this method won't work in the case the id fields are not set
        if (!(object instanceof Depot)) {
            return false;
        }
        Depot other = (Depot) object;
        if ((this.iddepot == null && other.iddepot != null) || (this.iddepot != null && !this.iddepot.equals(other.iddepot))) {
            return false;
        }
        return true;
    }

    @Override
    public String toString() {
        return "model.entity.Depot[ iddepot=" + iddepot + " ]";
    }
    
}
